package com.adminpanel.action;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

import com.adminpanel.modelbean.LogCount;
import com.adminpanel.modelbean.UserBean;
import com.adminpanel.service.LogServices;


@Controller
@SessionAttributes("loginuser")
public class GraphsController {
	
	@Resource(name = "logServices")
	private LogServices logServices;
	
	@RequestMapping("graphs")
	public String getGraphInfo() {
		return "graphs";
	}
	
	//先返回json看结果
	@RequestMapping(value="/graphs/countresult",method = RequestMethod.GET)
	//@ResponseBody
	public ModelAndView geturl(@ModelAttribute("loginuser") UserBean userBean,@RequestParam("fd") String fd,@RequestParam("td") String td){
		
		List<LogCount> userlogp = logServices.getRc(userBean.getId(), fd, td);
		ModelAndView mav = new ModelAndView("jaxb2MarshallingView");
		//ModelMap modelMap = new ModelMap();
		//mav.addAttribute("userlogp", logServices.getRc(userBean.getId(), fd, td));
		
		mav.addObject("userlogp",userlogp);
	
		return mav;
		
	}
	
	@RequestMapping(value="/graphs/test111",method = RequestMethod.GET)
	//@ResponseBody
	public ModelAndView geturla(){
		ModelAndView mav = new ModelAndView("jaxb2MarshallingView");
		
        LogCount bean = new LogCount();

        bean.setCounts("111");

        bean.setCreate_day("2010-5-2");

       mav.addObject(bean);
	
		return mav;
		
	}
}
